package threadlocal;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;

public class WeakReferenceTest {
	public static void main(String[] args) {
		Thread thread = Thread.currentThread();
		ThreadLocal<Integer> local = new ThreadLocal<>();
		local.set(1);
		WeakReference<Object> weakReference=new WeakReference<Object>(new Object());
		System.out.println("beforeGC:"+weakReference.get());
		List<Byte[]> list=new ArrayList<>();
		for(int i=0;i<100;i++){
			list.add(new Byte[1024]);
		}

		System.out.println(local.get());
		System.out.println("afterGC:"+weakReference.get());
	}
}
